/*
 * AttributeConditionImpl.cpp
 *
 *  Created on: 2010-8-28
 *      Author: Xairy
 */

#include "ConditionImpl.h"

AttributeConditionImpl::AttributeConditionImpl()
{

}

AttributeConditionImpl::AttributeConditionImpl(const string& _localName,
											   const string& _value)
	:localName(_localName), value(_value)
{

}

AttributeConditionImpl::~AttributeConditionImpl()
{

}

Condition::ConditionType AttributeConditionImpl::getConditionType()const
{
	return Condition::SAC_ATTRIBUTE_CONDITION;
}

Condition* AttributeConditionImpl::Copy()const
{
	return new AttributeConditionImpl(localName, value);
}

const string* AttributeConditionImpl::getNameSpaceURI()const
{
	return NULL;
}

const string* AttributeConditionImpl::getLocalName()const
{
	return &localName;
}

const string* AttributeConditionImpl::getValue()const
{
	return &value;
}

bool AttributeConditionImpl::getSpecified()const
{
	return true;
}

const string* AttributeConditionImpl::toString()const
{
	string* result = NULL;
	try
	{
		result = new string;
		result->append("[");
		result->append(localName);
		if(!value.empty())
		{
			result->append("=");
			result->append(value);
		}
		result->append("]");
	}catch(std::exception& e)
	{
		if(result)
			delete result;
		return NULL;
	}

	return result;
}


